<% prefix = api.out_name -%>
<% is_api_mi = api.is_a?(Api::ApiMultiInvoke) -%>
def build_<%= prefix -%>_parameters(opts<%= is_api_mi ? ", array_index" : "" %>):
    params = dict()

<%= lines(build_expand_properties(api.parameters, "opts, " + (is_api_mi ? "array_index" : "None"), prefix, "params"), 1) -%>
<% if api.msg_prefix.nil? -%>
    return params
<% else -%>
    if not params:
        return params

<%   items = api.msg_prefix.split(".")
     array_items = api.msg_prefix_array_items || []
-%>
<%   while !items.empty? do -%>
<%     ai = items.join(".") -%>
<%     if array_items.include?(ai) -%>
    params = {"<%= items.pop %>": [params]}
<%     else -%>
    params = {"<%= items.pop %>": params}
<%     end%>
<%   end -%>
    return params
<% end -%>
<% api.parameters.each do |prop| -%>
<%= lines(build_expand_method(resource, prefix, prop)) -%>
<% end -%>
